$(function(){
	toastr.options = {  
	        closeButton: false,  
	        debug: false,  
	        progressBar: true,  
	        positionClass: "toast-top-right",  
	        onclick: null,  
	        showDuration: "300",  //显示动作时间 
	        hideDuration: "1000",  
	        timeOut: "2000",  
	        extendedTimeOut: "1000",  
	        showEasing: "swing",  
	        hideEasing: "linear",  
	        showMethod: "fadeIn",  
	        hideMethod: "fadeOut"  
	    };  
	
});

function openyem(title,url,width,height){
	 var diag = new top.Dialog();
	 diag.Drag=true;
	 diag.Title =title;
	 diag.URL = url;
	 diag.Width = width;
	 diag.Height = height;
	 diag.CancelEvent = function(){ //关闭事件
		$("#table_list").trigger("reloadGrid");
		diag.close();
	 };
	 diag.show();
}//是通过这个方法打开的子窗体

function swalopen(id,url){
	swal({
	    title: "您确定要删除该条记录吗",
	    text: "删除后将无法恢复，请谨慎操作！",
	    type: "warning",
	    showCancelButton: true,
	    confirmButtonColor: "#DD6B55",
	    confirmButtonText: "删除",
	    animation:"slide-from-bottom",
	    cancelButtonText:"取消",
	    closeOnConfirm: true
	},function (){
		 $.ajax({url:url+"?id="+id,
			 dataType:'json',
			 success:function(data){
				if(data.code==200){
					toastr.success("删除成功");
					$("#table_list").trigger("reloadGrid");
					
		    	}else{
		    		toastr.error("出现错误，请稍后再试！");
		    	}
			 },
			error:function(){
				toastr.error("未知错误，请稍后再试！");
			}
		 });
	});
};



function getFileSize() {
    var btnsave = document.getElementById("sub_Import"); 
    var tbody = document.getElementById("tbody");
/*    btnsave.disabled = true; */
  		 var f = document.getElementById("file_Up").files;//获得所有上传文件的一个数组
  		 var htm = "";
  		 $.each(f, function(index, item){
  			  var imgele = new Image();
			  var thesrc = window.URL.createObjectURL(item);
  			htm+="<tr class='template-upload fade in'><td>"
  				+"<img  height='60' width='60'  src='"+thesrc+"'   style='cursor: pointer;' /></td>"
  				+"<td><p class='name'>"+item.name+"</p>"
  				+"<strong class='error text-danger label label-danger'></strong></td>"
  				+"<td><p class='size'>"+(item.size/1024).toFixed(2)+" KB</p></td>"
  				+"<td style='color: red;'>待上传</td><td><select name='types'>"
  				+"<option value='1'>学历档案</option><option value='2'>政治面貌</option>"
			    +"<option value='3'>单位证明</option><option value='4'>个人履历</option></select></td></tr>";
  		 });
  		tbodyt.innerHTML = htm;
  		/*btnsave.disabled = false;*/
	}

function filedelete(flieid,ids,attributetype){
	$.ajax({
       	url:'filestorage/deletefile',
       	data:{
       		id:flieid,
       		ids:ids,
       		attributetype:attributetype
       	},
       	type:'post',
       	dataType:"json",
       	success:function(data){
       	/* 	var ps = 0; */
       		var htm ="";
       		 $.each(data, function(index, item){
       			 var img ="";
       				 img ="<td><img height='60' width='60' src='"+"static/upload/"+item.flieName+"'/></td>";
       			 var shuj = "";
       			 if(item.type==4){
       				 shuj ="个人履历";
       				/*  ps=1; */
       				 //document.getElementById("fmt").style="display: none";
       			 }else if(item.type==3){
       				 shuj ="单位证明";
       			 }else if(item.type==2){
       				 shuj="政治面貌";
       			 }else if(item.type==1){
       				 shuj="学历档案";
       			 }
       			 htm+="<tr class='template-upload fade in'>"
	      				+img
	      				+"<td><p class='name'><a  target='_blank' href='"+"static/upload/"+item.flieName+"'>"+item.flieName+"</a></p>"
	      				+"<strong class='error text-danger label label-danger'></strong></td>"
	      				+"<td><p class='size'>"+item.flieSize+"kb</td>"
	      				+"<td> <p class='shuom'>"+shuj+"</td>"
	      				+"<td><strong class='error text-danger label label-danger' style='color: white;cursor:pointer;' onclick='filedelete("+item.flieId+","+ids+","+attributetype+")'>删除</strong></td></tr>";
       		 });
       		 tbody.innerHTML = htm;
       		 alert("删除成功");
       		top.Dialog.close();
       		 /*document.getElementById("reset").click();*/
       		/*  if(ps==0){
       			 document.getElementById("fmt").style="display: inline-block";
       		 } */
       	}
    }); 
}

//政治面貌
function getFileSizezzmm() {
    var zzmm = document.getElementById("zzmm");
/*    btnsave.disabled = true; */
  		 var f = document.getElementById("file_Upzzmm").files;//获得所有上传文件的一个数组
  		 var htm = "";
  		 $.each(f, function(index, item){
  			  var imgele = new Image();
			  var thesrc = window.URL.createObjectURL(item);
  			htm+="<tr class='template-upload fade in'><td>"
  				+"<img  height='60' width='60'  src='"+thesrc+"'   style='cursor: pointer;' /></td>"
  				+"<td><p class='name'>"+item.name+"</p>"
  				+"<strong class='error text-danger label label-danger'></strong></td>"
  				+"<td><p class='size'>"+(item.size/1024).toFixed(2)+" KB</p></td>"
  				+"<td style='color: red;'>待上传</td><td>政治面貌</td></tr>";
  		 });
  		zzmm.innerHTML = htm;
  		/*btnsave.disabled = false;*/
	}

//学历档案
function getFileSizexlda() {
    var xlda = document.getElementById("xlda");
/*    btnsave.disabled = true; */
  		 var f = document.getElementById("file_Upxlda").files;//获得所有上传文件的一个数组
  		 var htm = "";
  		 $.each(f, function(index, item){
  			  var imgele = new Image();
			  var thesrc = window.URL.createObjectURL(item);
  			htm+="<tr class='template-upload fade in'><td>"
  				+"<img  height='60' width='60'  src='"+thesrc+"'   style='cursor: pointer;' /></td>"
  				+"<td><p class='name'>"+item.name+"</p>"
  				+"<strong class='error text-danger label label-danger'></strong></td>"
  				+"<td><p class='size'>"+(item.size/1024).toFixed(2)+" KB</p></td>"
  				+"<td style='color: red;'>待上传</td><td>学历档案</td></tr>";
  		 });
  		xlda.innerHTML = htm;
  		/*btnsave.disabled = false;*/
	}

//单位证明
function getFileSizedwzm() {
    var dwzm = document.getElementById("dwzm");
/*    btnsave.disabled = true; */
  		 var f = document.getElementById("file_Updwzm").files;//获得所有上传文件的一个数组
  		 var htm = "";
  		 $.each(f, function(index, item){
  			  var imgele = new Image();
			  var thesrc = window.URL.createObjectURL(item);
  			htm+="<tr class='template-upload fade in'><td>"
  				+"<img  height='60' width='60'  src='"+thesrc+"'   style='cursor: pointer;' /></td>"
  				+"<td><p class='name'>"+item.name+"</p>"
  				+"<strong class='error text-danger label label-danger'></strong></td>"
  				+"<td><p class='size'>"+(item.size/1024).toFixed(2)+" KB</p></td>"
  				+"<td style='color: red;'>待上传</td><td>单位证明</td></tr>";
  		 });
  		dwzm.innerHTML = htm;
  		/*btnsave.disabled = false;*/
	}

//个人履历
function getFileSizegrll() {
    var grll = document.getElementById("grll");
/*    btnsave.disabled = true; */
  		 var f = document.getElementById("file_Upgrll").files;//获得所有上传文件的一个数组
  		 var htm = "";
  		 $.each(f, function(index, item){
  			  var imgele = new Image();
			  var thesrc = window.URL.createObjectURL(item);
  			htm+="<tr class='template-upload fade in'><td>"
  				+"<img  height='60' width='60'  src='"+thesrc+"'   style='cursor: pointer;' /></td>"
  				+"<td><p class='name'>"+item.name+"</p>"
  				+"<strong class='error text-danger label label-danger'></strong></td>"
  				+"<td><p class='size'>"+(item.size/1024).toFixed(2)+" KB</p></td>"
  				+"<td style='color: red;'>待上传</td><td>个人履历</td></tr>";
  		 });
  		grll.innerHTML = htm;
  		/*btnsave.disabled = false;*/
	}

function ckdt(url,type,name,urls){
	var ss = "";
	if(type==1){
		ss="学历档案";
	}else if(type==2){
		ss="政治面貌";
	}else if(type==3){
		ss="单位证明";
	}else if(type==4){
		ss="个人履历";
	}
	var diag = new top.Dialog();
	 diag.Drag=true;
	 diag.Title ="查看"+name+"的"+ss;
	 diag.URL = urls+"?url=" + url;
	 diag.Width = 1000;
	 diag.Height = 700;
	 diag.CancelEvent = function(){ //关闭事件
		diag.close();
	 };
	 diag.show();
}
